<?php
#echo $HTTP_RAW_POST_DATA;
$xml = file_get_contents('php://input');
header("content-type:text/html; charset=utf-8"); //设置编码/*
$con = mysql_connect("localhost","kankanxiaxia_holy","lingqq");
if (!$con) {
  die('Could not connect: ' . mysql_error());
}*/	$mysql = new SaeMysql(); #	$sql = "SELECT * FROM `meta` LIMIT 10";#	$data = $mysql->getData( $sql );#     $name = strip_tags( $_REQUEST['name'] );#     $age = intval( $_REQUEST['age'] );#     $sql = "INSERT  INTO `user` ( `name` , `age` , `regtime` ) VALUES ( '"  . $mysql->escape( $name ) . "' , '" . intval( $age ) . "' , NOW() ) ";#     $mysql->runSql( $sql );
mysql_select_db("kankanxiaxia_meta", $con);
$xml = simplexml_load_string("$xml");

foreach($xml->children() as $child) {
		if($child->download) {
			$sql = "INSERT INTO `meta` ( `id` , `title` , `img` , `link` , `download` , `reserve` )
			VALUES ( NULL , '$child->title', '$child->img', '$child->link', '$child->download', NULL )";
		    $mysql->runSql( $sql );/*			if (!mysql_query($sql,$con)) {
				die('Error: ' . mysql_error());
			}			*/
		}
}

//$result = mysql_query("SELECT * FROM meta");#	$sql = "SELECT * FROM `meta` LIMIT 10";	$result = $mysql->getData( "SELECT * FROM meta" );

//while($row = mysql_fetch_array($result))	foreach ($result as $key=>$row) {
 		echo $key . " " . $row['title'];
		echo "<br />";	}
$mysql->closeDb();
exit('OK1');
//save type
/*
if($xml!=''){
 $fp = fopen('meta.xml','w');
 fwrite($fp,$xml);
 fclose($fp);
 exit('OK1');
}
die('Fail');
*/
?>